package com.hsck.order.kds.login

import android.view.LayoutInflater
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import com.hjq.toast.Toaster
import com.hsck.order.kds.R
import com.hsck.order.kds.base.bean.SelectModel
import com.hsck.order.kds.base.common.jump
import com.hsck.order.kds.base.common.shortToast
import com.hsck.order.kds.base.utils.setOnSingleClickListener
import com.hsck.order.kds.base.isnoam.view.BaseActivity
import com.hsck.order.kds.databinding.ActivityLoginBinding
import com.hsck.order.kds.login.adapter.LoginAdapter
import com.hsck.order.kds.main.MainActivity


class LoginActivity : BaseActivity<ActivityLoginBinding>() {

    private val adapter by lazy { LoginAdapter(R.layout.item_login) }
    override fun inflateBinding(inflater: LayoutInflater): ActivityLoginBinding {
        return ActivityLoginBinding.inflate(inflater)
    }

    override fun initData() {
        super.initData()

        binding.relLoginGo.setOnSingleClickListener {
            binding.linLoginRight1.visibility = View.GONE
            binding.relLoginRight2.visibility = View.VISIBLE
        }
        binding.imgRelLoginRight2Close.setOnSingleClickListener {
            binding.linLoginRight1.visibility = View.VISIBLE
            binding.relLoginRight2.visibility = View.GONE
        }

        binding.btnLoginSynchronous.setOnSingleClickListener {
            jump(SynchronizeActivity::class.java)
        }
        binding.btnLoginLogin.setOnSingleClickListener {
//            if (checkInput()){
//
//            }
            jump(MainActivity::class.java)

        }
        binding.rvLogin.layoutManager = GridLayoutManager(this, 3)
        binding.rvLogin.adapter = adapter
        val list = listOf(true, false, false, false, false, false, false, false, false)
        adapter.datas = list

        adapter.onItemClick = {

        }
    }


    /**
     * 检查输入数据是否合法
     */
    private fun checkInput(): Boolean {
        when {
            binding.edtLoginPassword.text.toString().trim() == "" -> {
                Toaster.show("请输入密码")
                return false
            }
        }
        return true
    }

}